#include <QMainWindow>
#include <QToolButton>
#include <QComboBox>
#include <QLineEdit>
#include <QLabel>
#include <QDialog>

#include <qwt_plot.h>
#include <cv.h>

#include <widgets.hpp>

class QStackedWidget;
class QComboBox;
class QWebcam;
class QPushButton;
class QSpinBox;
class QProgressBar;
class TCTracker;

using namespace TCWidgets;

class SaveDialog : public QDialog
{
    Q_OBJECT
public:
    SaveDialog(QWidget *);
    QString getText() const;
    int     getSVNP() const;

private:
    QLineEdit   *m_LineEdit;
    QComboBox   *m_SVNP;
};

class MainWindow : public QMainWindow
{
	Q_OBJECT
public:
	MainWindow(QWidget *parent = 0);
    void initialize();

private:
    QComboBox       *m_DeviceList;
    QComboBox       *m_Resolutions;
    QWebcam         *m_Webcam;
    QLabel          *m_CLImageCount;
    QSpinBox        *m_HorzCorners;
    QSpinBox        *m_VertCorners;
    QProgressBar    *m_Progress;
    QLabel          *m_PLabel;
    QTabWidget      *m_BTools;
    QwtPlot         *m_Plot;
    QStackedWidget  *m_Stacked;
    TCTracker       *m_Tracker;

    void         loadDevicesList();
    void         loadDeviceResolutions();
    int          loadDeviceFrameRates();
    QWidget     *createCameraConfigurationWidget();
    QWidget     *createCameraCalibrationWidget();

private slots:
    void changeColor(QColor);
    void setColor();
    void clearPlot();
    void showCalibrationDetails();
    void updateImageCount();
    void areaSelected();
    void connectDevice(int);
    void changeResolution(int);
    void showRGB(bool);
    void pickArea(bool);
    void onTrackingStoped();
    void storeCalibrationImage();
    void computeCalibrationParameters();
    void save();
};
